<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>margin塌陷问题</title>
  <style>
    .demo-p {
      margin-top: 20px;
      width: 200px;
      height: 120px;
      background-color: paleturquoise;
    }

    p {
      margin-top: 40px;
      width: 80px;
      height: 50px;
      background-color: chocolate;
    }

    .f {
      height: 1px;
      width: 100%;
      background-color: black;
    }

    .p1 { border: 1px solid transparent;}

    .p2 {padding-top: 1px;}

    .p3 {overflow: hidden;}
  </style>
</head>

<body>
  <div class="demo-p">
    <p></p>
  </div>
  <div class="f"></div>

  <div class="demo-p p1">
    <p></p>
  </div>
  <div class="f"></div>

  <div class="demo-p p2">
    <p></p>
  </div>
  <div class="f"></div>

  <div class="demo-p p3">
    <p></p>
  </div>

</body>

</html>